package com.geologyoa.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.DecimalFormat;
import java.util.Iterator;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.XMLWriter;

import com.geologyoa.domain.Dwqk01;
import com.geologyoa.service.SystemManager;
import com.geologyoa.service.SystemManagerImpl;

public class SearchAllDwqk01 extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
        doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		SystemManager sys=new SystemManagerImpl();
		List<Dwqk01> dwqkList=sys.SearchAllDwqk();
		Document document=DocumentHelper.createDocument();
		if(dwqkList!=null)
		{
			Element fwlistElement =document.addElement("dwqkList");
			fwlistElement.addAttribute("size", (new StringBuilder(String.valueOf(dwqkList.size()))).toString());
			Dwqk01 dwqk01;
			Element fwElement;
			for(Iterator iterator=dwqkList.iterator();iterator.hasNext();)
			{
				dwqk01 = (Dwqk01)iterator.next();
				fwElement=fwlistElement.addElement("dwqkInfo");
				//modify by cuiyi 20130330 将索引值放开 取出来 传递给前台
				fwElement.addAttribute("DWQK0101", dwqk01.getDwqk0101().toString());
				fwElement.addAttribute("DWQK0102", dwqk01.getDwqk0102());
				fwElement.addAttribute("DWQK0103", dwqk01.getDwqk0103());
				fwElement.addAttribute("DWQK0104", dwqk01.getDwqk0104());
				fwElement.addAttribute("DWQK0105", dwqk01.getDwqk0105());
				fwElement.addAttribute("DWQK0106", dwqk01.getDwqk0106());
				fwElement.addAttribute("DWQK0107", dwqk01.getDwqk0107());
				fwElement.addAttribute("DWQK0108", dwqk01.getDwqk0108());
				/// 强转是否有问题
				fwElement.addAttribute("DWQK0109", new DecimalFormat("0.00").format(dwqk01.getDwqk0109()));
				fwElement.addAttribute("DWQK0110", dwqk01.getDwqk0110());
				fwElement.addAttribute("DWQK0111", dwqk01.getDwqk0111());
				fwElement.addAttribute("DWQK0113", dwqk01.getDwqk0113());
				fwElement.addAttribute("DWQK0114", dwqk01.getDwqk0114());
				fwElement.addAttribute("DWQK0116", dwqk01.getDwqk0116());
				fwElement.addAttribute("DWQK0117", dwqk01.getDwqk0117());
				fwElement.addAttribute("DWQK0118", dwqk01.getDwqk0118());
			}
		}
		StringWriter xmlout = new StringWriter();
		XMLWriter output = new XMLWriter(xmlout);
		output.write(document);
		response.setContentType("text/html;charset=utf-8");
		response.setHeader("Cache-Control", "no-cache");
		response.setHeader("Expires", "0");
		response.setHeader("Pragma", "No-cache");
		response.getWriter().write(xmlout.toString());
	
	}

}
